var ajaxHelper = require("../../utils/ajaxhelp");
let token = wx.getStorageSync('token');
const serviceUrl = getApp().globalData.serviceUrl;


const CreaterReservation = (Reservation={}) => {
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/Reservation/CreaterReservation", {
		'Authorization': 'Bearer ' + token
	}, "Post", Reservation)
}

const UpadateReservation = (Reservation = {}) => {
  token = wx.getStorageSync('token');
  return ajaxHelper.promiseRequst(serviceUrl + "/api/Reservation/UpdateReservation", {
    'Authorization': 'Bearer ' + token
  }, "Post", Reservation)
}

const QueryReservationByIsHospital = (startdate,enddate,ishospital,pageNum,pageSize) => {
  token = wx.getStorageSync('token');
  return ajaxHelper.promiseRequst(serviceUrl + "/api/Reservation/QueryReservationByIstohospital",{ 'Authorization': 'Bearer ' + token }, "GET",{
    startdate: startdate,
    enddate: enddate,
    ishospital: ishospital,
    pageIndex: pageNum,
    pageSize: pageSize
  })
}

const FetchReservationById = (reservationid) => {
  token = wx.getStorageSync('token');
  return ajaxHelper.promiseRequst(serviceUrl + "/api/Reservation/FetchReservationById", { 'Authorization': 'Bearer ' + token }, "GET", {
    reservationid: reservationid
  })
}

module.exports = {
	CreaterReservation,
  QueryReservationByIsHospital,
  FetchReservationById,
  UpadateReservation,
}